#! /bin/bash
# GNU GPL yo!  protect freedom!
# copyleft, Digit (of wastedartist and witch[linux] fame, 2013

echo "warning, this is still alphaware and noobware." 
echo "you have been warned"
sleep 1
echo "you will likely want to run something like:"
echo "ii -i ~/irc -s irc.libera.chat -n whatevernickuwant"
echo "and then to join manually:"
echo "echo \"/join #witchlinux\" > ~/irc/irc.libera.chat/in"
echo "(can use perpetualii input for simple /j or /join commands)"
echo "and then to see the output, instead of \"tail -f \#witchlinux\", try:"
echo "hiir \#witchlinux"
echo "see man ii for more."
echo "once you know what you're doing, you can comment out these introduction lines with a #"

#this script is for creating a persistent input prompt for ii.  usefull if, for example, you have two panes in tmux, one running the "tail -f out", and the other, for inputs...  now instead of echo "what you want to say" > ~/irc/where.you.want/\#tosayit/in, you can just type what you want.  :)

#for development intermediary purposes, these variables /-are-/ were statically defined

echo "enter your irc network, or enter for default [irc.libera.chat]:"
read -e -i irc.libera.chat SERV
#SERV="irc.libera.chat"

echo "enter your irc network, or enter for default [#witchlinux]:" 
read -e -i \#witchlinux CHAN
#CHAN="#witchlinux"

##now defined in sayer.
#SAY=sayer

sayer() {
read SAY
poster
}

poster() {
echo "$SAY" > ~/irc/$SERV/$CHAN/in
sayer
}

#this initiates the pseudo-loop of two functions, sayer and poster (each re-initiating the other at the end).  sayer lets you define what you want to say, and once you hit enter, poster posts it and once it is posted, it goes back to sayer, ready for another thing to be said.  clever eh. ;)
sayer

##### add "tail -f" and a -t to the read, so it refreshes every few seconds... but do it in a way that's not going to have things automatically be sent.   ... yes, this is a potential path to have the input and output on the same terminal.   
#####... maybe consider adding a clear to the input prompt?  ... or at least consider that once up-cursor retrieves past messages.  ... can maybe do that with some kind of inbuilt bash keybind/command... or a command method of tee'ing and tailing to retrieve previous posted ....  idk... lots of ways it could be done.  just need to clearly suss a clean n useable way, and implement.

####### also need to make the audio notifications system...  just had a thought... maybe something like a tail -f -n 1, piped to the grepings and soxings, the -n 1 being the key bit to prevent over-repetitious audio notifications.

######## user list.  should be easy to create.  same with whois, just extract it from the network's connection channel.

